<?php
class StudentProvincesController extends AppController {

    public $name = 'StudentProvinces';
    public $helpers = array('Html', 'Form');

    public function index() {
        $this->StudentProvince->recursive = 0;
        $this->set('studentProvinces', $this->paginate());
    }

    public function view($id = null) {
        if (!$id) {
            $this->Session->setFlash(__('Invalid StudentProvince.', true));
            $this->redirect(array('action'=>'index'));
        }
        $this->set('studentProvince', $this->StudentProvince->read(null, $id));
    }

    public function add() {
        if (!empty($this->data)) {
            $this->StudentProvince->create();
            if ($this->StudentProvince->save($this->data)) {
                $this->Session->setFlash(__('The StudentProvince has been saved', true));
                $this->redirect(array('action'=>'index'));
            } else {
                $this->Session->setFlash(__('The StudentProvince could not be saved. Please, try again.', true));
            }
        }
    }

    public function edit($id = null) {
        if (!$id && empty($this->data)) {
            $this->Session->setFlash(__('Invalid StudentProvince', true));
            $this->redirect(array('action'=>'index'));
        }
        if (!empty($this->data)) {
            if ($this->StudentProvince->save($this->data)) {
                $this->Session->setFlash(__('The StudentProvince has been saved', true));
                $this->redirect(array('action'=>'index'));
            } else {
                $this->Session->setFlash(__('The StudentProvince could not be saved. Please, try again.', true));
            }
        }
        if (empty($this->data)) {
            $this->data = $this->StudentProvince->read(null, $id);
        }
    }

}
?>